define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function($, undefined, Backend, Table, Form) {
    var Controller = {
        index: function() {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'order/index' + location.search,
                    add_url: 'order/add',
                    edit_url: 'order/edit',
                    del_url: 'order/del',
                    multi_url: 'order/multi',
                    import_url: 'order/import',
                    table: 'order',
                }
            });
            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [{
                        checkbox: true
                    }, {
                        field: 'id',
                        title: __('Id')
                    }, {
                        field: 'openid',
                        title: __('Openid'),
                        operate: 'LIKE'
                    }, {
                        field: 'transction_id',
                        title: __('Transction_id'),
                        operate: 'LIKE'
                    }, {
                        field: 'order_no',
                        title: __('Order_no'),
                        operate: 'LIKE'
                    }, {
                        field: 'desk_id',
                        title: __('Desk_id')
                    }, {
                        field: 'total_fee',
                        title: __('Total_fee')
                    },{
                        field: 'status',
                        title: __('Status'),
                        searchList: {
                            "paid": __('Status paid'),
                            "unpaid": __('Status unpaid')
                        },
                        formatter: Table.api.formatter.status
                    }, {
                        field: 'paytime',
                        title: __('Paytime'),
                        operate: 'RANGE',
                        addclass: 'datetimerange',
                        autocomplete: false,
                        formatter: Table.api.formatter.datetime
                    }, {
                        field: 'createtime',
                        title: __('Createtime'),
                        operate: 'RANGE',
                        addclass: 'datetimerange',
                        autocomplete: false,
                        formatter: Table.api.formatter.datetime
                    }, {
                        field: 'operate',
                        title: __('Operate'),
                        table: table,
                        events: Table.api.events.operate,
                        formatter: Table.api.formatter.operate
                    }, {
                        field: 'buttons',
                        title: __('订单详情'),
                        table: table,
                        events: Table.api.events.operate,
                        buttons: [{
                            name: 'detail',
                            text: __('订单详情'),
                            title: __('订单详情'),
                            classname: 'btn btn-xs btn-success btn-dialog',
                            icon: 'fa fa-list',
                            url: './order_detail/index',
                           
                        }],
                        formatter: Table.api.formatter.buttons
                    }]
                ]
            });
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function() {
            Controller.api.bindevent();
        },
        edit: function() {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function() {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});